/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.unipar.cursoweb.service;

import br.com.unipar.cursoweb.modelo.Funcionario;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Service;

/**
 *
 * @author Thiago
 */
@Service("funcionarioService")
public class FuncionarioServiceImpl extends GenericServiceImpl<Funcionario> implements FuncionarioService {

    @Override
    public List<Funcionario> consulta(String cpf) {
        Criteria crit = ((Session) entityManager.getDelegate()).createCriteria(Funcionario.class);
        if (cpf != null) {
            crit.add(Restrictions.ilike("cpf", cpf, MatchMode.ANYWHERE));
        }
        return crit.list();
    }
}
